package cn.edu.zzu.demo05Thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestCreate {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        new MyThread().start();

        MyThread2 myThread2 = new MyThread2();
        new Thread(myThread2).start();

        //lambda 函数式接口 静态代理
        new Thread(()->{
            System.out.println("mythread4!");
        }).start();

        FutureTask<Integer> integerFutureTask = new FutureTask<Integer>(new MuThread3());
        new Thread(integerFutureTask).start();
        Integer integer = integerFutureTask.get();
        System.out.println(integer);

    }
}
class MyThread extends Thread{
    @Override
    public void run() {
        System.out.println("mythread1!");
    }
}

class MyThread2 implements Runnable{
    @Override
    public void run() {
        System.out.println("mythread2!");
    }
}
class MuThread3 implements Callable<Integer>{
    @Override
    public Integer call() throws Exception {
        System.out.println("mythread3!");
        return 100;
    }
}